package net.learn.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import net.learn.framework.common.page.PageResult;
import net.learn.framework.common.service.impl.BaseServiceImpl;
import net.learn.system.convert.SysJudgeConvert;
import net.learn.system.convert.SysJudgeDetailConvert;
import net.learn.system.dao.SysJudgeDetailDao;
import net.learn.system.entity.SysJudgeDetailEntity;
import net.learn.system.entity.SysJudgeEntity;
import net.learn.system.query.SysJudgeDetailQuery;
import net.learn.system.query.SysJudgeQuery;
import net.learn.system.service.SysJudgeDetailService;
import net.learn.system.utils.UUIDUtil;
import net.learn.system.vo.SysJudgeDetailVO;
import net.learn.system.vo.SysJudgeVO;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author 李立志
 * @since 2022-04-01
 */
@Service
public class SysJudgeDetailServiceImpl extends BaseServiceImpl<SysJudgeDetailDao, SysJudgeDetailEntity> implements SysJudgeDetailService {
    @Override
    public Boolean addJudgeDetail(SysJudgeDetailVO vo){
        SysJudgeDetailEntity entity = SysJudgeDetailConvert.INSTANCE.convert(vo);
        String uuid= UUIDUtil.uuid();
        entity.setUid(uuid);
        return baseMapper.insert(entity)>0;
    }
    @Override
    public Boolean updateJudgeDetail(SysJudgeDetailVO vo){
        SysJudgeDetailEntity entity = SysJudgeDetailConvert.INSTANCE.convert(vo);
        return baseMapper.updateById(entity) > 0;
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void delete(List<Long> idList) {

        removeByIds(idList);
    }
    @Override
    public List<SysJudgeDetailVO> qryJudgeDetailList() {
        QueryWrapper queryWrapper = new QueryWrapper();
        return baseMapper.selectList(queryWrapper);
    }
    @Override
    public List<SysJudgeDetailVO> getJudgeDetailArray() {
        return baseMapper.getJudgeDetailArray();
    }
    @Override
    public List<SysJudgeDetailVO> qryPaperJudgeList(SysJudgeDetailQuery qry) {
        return baseMapper.qryPaperJudgeList(qry);
    }
    @Override
    public List<SysJudgeDetailVO> qryPaperJudgeCondition(SysJudgeDetailQuery qry) {
        return baseMapper.qryPaperJudgeCondition(qry);
    }
    @Override
    public PageResult<SysJudgeDetailVO> qryJudgeDetailListPage(SysJudgeDetailQuery query) {
        IPage<SysJudgeDetailEntity> page = baseMapper.qryJudgeDetailListPage(getPage(query), query);

        return new PageResult<>(SysJudgeDetailConvert.INSTANCE.convertList(page.getRecords()), page.getTotal());
    }
}
